<!DOCTYPE html>
<html>
@include('backend.global.includeHead')
<body class="fixed-header fixed-leftmenu catalog-page">
<div id="theme-wrapper">
    @include('backend.global.includeHeadNav')
    <div id="page-wrapper" class="container">
        <div class="row">
            @include('backend.global.includeSideNav')
            <div id="content-wrapper">
                <div class="row">
                    <div class="col-lg-12">
                        <ol class="breadcrumb">
                            <li><a href="/">控制台</a></li>
                            <li class="active"><span>分类管理</span></li>
                        </ol>
                        <h1>分类管理</h1>
                        <div class="panel panel-default">
                            <div class="panel-body">
                                <div class="clearfix"><a href="/admin/categoryNew/" class="btn btn-primary pull-right"
                                                         data-permission-action="category-new"><i
                                                class="fa fa-plus-circle"></i>&nbsp;新增一级分类</a></div>
                                <div class="table-responsive">
                                    <table class="table table-hover">
                                        <thead>
                                        <tr>
                                            <th style="width: 30%;">一级分类</th>
                                            <th class="text-left" style="width: 40%;">二级分类</th>
                                            <th class="text-center" style="width: 15%;">排序</th>
                                            <th style="width: 15%;">&nbsp;</th>
                                        </tr>
                                        </thead>
                                        <tbody>

                                        <tr>
                                            <td>家居百货</td>
                                            <td class="text-left">


                                                日用／家纺&nbsp;,&nbsp;厨具／餐具&nbsp;,&nbsp;洗晒／收纳&nbsp;,&nbsp;美容护肤&nbsp;,&nbsp;礼品箱包
                                            </td>
                                            <td class="text-center">
                                                90
                                            </td>
                                            <td class="text-right">
                                                <div class="normal">
                                                    <a href="/admin/categoryUpdate/39" class="table-link text-info"
                                                       data-toggle="tooltip" data-placement="top" title="编辑"
                                                       data-permission-action="category-update"><i
                                                                class="fa fa-pencil-square-o fa-lg fa-fw"></i></a>
                                                    <a href="javascript:;" class="table-link text-danger js-delete"
                                                       data-toggle="tooltip" data-placement="top" title="删除"
                                                       data-permission-action="category-delete"><i
                                                                class="fa fa-trash-o fa-lg fa-fw"></i></a>
                                                </div>
                                                <div class="delete">
                                                    <a href="javascript:;" class="btn btn-danger js-confirm-delete"
                                                       data-categoryId="39" data-permission-action="category-delete">确定删除</a>
                                                    <a href="javascript:;"
                                                       class="btn btn-default js-delete-cancel">取消</a>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>数码家电</td>
                                            <td class="text-left">


                                                生活电器&nbsp;,&nbsp;厨房电器&nbsp;,&nbsp;个护健康&nbsp;,&nbsp;数码影音
                                            </td>
                                            <td class="text-center">
                                                80
                                            </td>
                                            <td class="text-right">
                                                <div class="normal">
                                                    <a href="/admin/categoryUpdate/1" class="table-link text-info"
                                                       data-toggle="tooltip" data-placement="top" title="编辑"
                                                       data-permission-action="category-update"><i
                                                                class="fa fa-pencil-square-o fa-lg fa-fw"></i></a>
                                                    <a href="javascript:;" class="table-link text-danger js-delete"
                                                       data-toggle="tooltip" data-placement="top" title="删除"
                                                       data-permission-action="category-delete"><i
                                                                class="fa fa-trash-o fa-lg fa-fw"></i></a>
                                                </div>
                                                <div class="delete">
                                                    <a href="javascript:;" class="btn btn-danger js-confirm-delete"
                                                       data-categoryId="1"
                                                       data-permission-action="category-delete">确定删除</a>
                                                    <a href="javascript:;"
                                                       class="btn btn-default js-delete-cancel">取消</a>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>汽车用品</td>
                                            <td class="text-left">


                                                汽车装饰&nbsp;,&nbsp;汽车配件
                                            </td>
                                            <td class="text-center">
                                                70
                                            </td>
                                            <td class="text-right">
                                                <div class="normal">
                                                    <a href="/admin/categoryUpdate/6" class="table-link text-info"
                                                       data-toggle="tooltip" data-placement="top" title="编辑"
                                                       data-permission-action="category-update"><i
                                                                class="fa fa-pencil-square-o fa-lg fa-fw"></i></a>
                                                    <a href="javascript:;" class="table-link text-danger js-delete"
                                                       data-toggle="tooltip" data-placement="top" title="删除"
                                                       data-permission-action="category-delete"><i
                                                                class="fa fa-trash-o fa-lg fa-fw"></i></a>
                                                </div>
                                                <div class="delete">
                                                    <a href="javascript:;" class="btn btn-danger js-confirm-delete"
                                                       data-categoryId="6"
                                                       data-permission-action="category-delete">确定删除</a>
                                                    <a href="javascript:;"
                                                       class="btn btn-default js-delete-cancel">取消</a>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>运动户外</td>
                                            <td class="text-left">


                                                户外用品&nbsp;,&nbsp;运动保健
                                            </td>
                                            <td class="text-center">
                                                60
                                            </td>
                                            <td class="text-right">
                                                <div class="normal">
                                                    <a href="/admin/categoryUpdate/5" class="table-link text-info"
                                                       data-toggle="tooltip" data-placement="top" title="编辑"
                                                       data-permission-action="category-update"><i
                                                                class="fa fa-pencil-square-o fa-lg fa-fw"></i></a>
                                                    <a href="javascript:;" class="table-link text-danger js-delete"
                                                       data-toggle="tooltip" data-placement="top" title="删除"
                                                       data-permission-action="category-delete"><i
                                                                class="fa fa-trash-o fa-lg fa-fw"></i></a>
                                                </div>
                                                <div class="delete">
                                                    <a href="javascript:;" class="btn btn-danger js-confirm-delete"
                                                       data-categoryId="5"
                                                       data-permission-action="category-delete">确定删除</a>
                                                    <a href="javascript:;"
                                                       class="btn btn-default js-delete-cancel">取消</a>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>电子票券</td>
                                            <td class="text-left">


                                                快餐&nbsp;,&nbsp;饮料／咖啡&nbsp;,&nbsp;烘培／蛋糕&nbsp;,&nbsp;冷饮／巧克力&nbsp;,&nbsp;超市／便利店&nbsp;,&nbsp;旅游
                                            </td>
                                            <td class="text-center">
                                                50
                                            </td>
                                            <td class="text-right">
                                                <div class="normal">
                                                    <a href="/admin/categoryUpdate/41" class="table-link text-info"
                                                       data-toggle="tooltip" data-placement="top" title="编辑"
                                                       data-permission-action="category-update"><i
                                                                class="fa fa-pencil-square-o fa-lg fa-fw"></i></a>
                                                    <a href="javascript:;" class="table-link text-danger js-delete"
                                                       data-toggle="tooltip" data-placement="top" title="删除"
                                                       data-permission-action="category-delete"><i
                                                                class="fa fa-trash-o fa-lg fa-fw"></i></a>
                                                </div>
                                                <div class="delete">
                                                    <a href="javascript:;" class="btn btn-danger js-confirm-delete"
                                                       data-categoryId="41" data-permission-action="category-delete">确定删除</a>
                                                    <a href="javascript:;"
                                                       class="btn btn-default js-delete-cancel">取消</a>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>投资理财</td>
                                            <td class="text-left">


                                                健康管理&nbsp;,&nbsp;投资理财&nbsp;,&nbsp;保险金融
                                            </td>
                                            <td class="text-center">
                                                40
                                            </td>
                                            <td class="text-right">
                                                <div class="normal">
                                                    <a href="/admin/categoryUpdate/42" class="table-link text-info"
                                                       data-toggle="tooltip" data-placement="top" title="编辑"
                                                       data-permission-action="category-update"><i
                                                                class="fa fa-pencil-square-o fa-lg fa-fw"></i></a>
                                                    <a href="javascript:;" class="table-link text-danger js-delete"
                                                       data-toggle="tooltip" data-placement="top" title="删除"
                                                       data-permission-action="category-delete"><i
                                                                class="fa fa-trash-o fa-lg fa-fw"></i></a>
                                                </div>
                                                <div class="delete">
                                                    <a href="javascript:;" class="btn btn-danger js-confirm-delete"
                                                       data-categoryId="42" data-permission-action="category-delete">确定删除</a>
                                                    <a href="javascript:;"
                                                       class="btn btn-default js-delete-cancel">取消</a>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>食品／饮料／酒</td>
                                            <td class="text-left">


                                                精选水果&nbsp;,&nbsp;粮油农副&nbsp;,&nbsp;保健品&nbsp;,&nbsp;精选肉类&nbsp;,&nbsp;休闲零食&nbsp;,&nbsp;饮品&nbsp;,&nbsp;酒类
                                            </td>
                                            <td class="text-center">
                                                30
                                            </td>
                                            <td class="text-right">
                                                <div class="normal">
                                                    <a href="/admin/categoryUpdate/43" class="table-link text-info"
                                                       data-toggle="tooltip" data-placement="top" title="编辑"
                                                       data-permission-action="category-update"><i
                                                                class="fa fa-pencil-square-o fa-lg fa-fw"></i></a>
                                                    <a href="javascript:;" class="table-link text-danger js-delete"
                                                       data-toggle="tooltip" data-placement="top" title="删除"
                                                       data-permission-action="category-delete"><i
                                                                class="fa fa-trash-o fa-lg fa-fw"></i></a>
                                                </div>
                                                <div class="delete">
                                                    <a href="javascript:;" class="btn btn-danger js-confirm-delete"
                                                       data-categoryId="43" data-permission-action="category-delete">确定删除</a>
                                                    <a href="javascript:;"
                                                       class="btn btn-default js-delete-cancel">取消</a>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>母婴专区</td>
                                            <td class="text-left">


                                                喂养用品&nbsp;,&nbsp;幼儿玩具
                                            </td>
                                            <td class="text-center">
                                                20
                                            </td>
                                            <td class="text-right">
                                                <div class="normal">
                                                    <a href="/admin/categoryUpdate/44" class="table-link text-info"
                                                       data-toggle="tooltip" data-placement="top" title="编辑"
                                                       data-permission-action="category-update"><i
                                                                class="fa fa-pencil-square-o fa-lg fa-fw"></i></a>
                                                    <a href="javascript:;" class="table-link text-danger js-delete"
                                                       data-toggle="tooltip" data-placement="top" title="删除"
                                                       data-permission-action="category-delete"><i
                                                                class="fa fa-trash-o fa-lg fa-fw"></i></a>
                                                </div>
                                                <div class="delete">
                                                    <a href="javascript:;" class="btn btn-danger js-confirm-delete"
                                                       data-categoryId="44" data-permission-action="category-delete">确定删除</a>
                                                    <a href="javascript:;"
                                                       class="btn btn-default js-delete-cancel">取消</a>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>生鲜</td>
                                            <td class="text-left">


                                                冰冻海鲜&nbsp;
                                            </td>
                                            <td class="text-center">
                                                4
                                            </td>
                                            <td class="text-right">
                                                <div class="normal">
                                                    <a href="/admin/categoryUpdate/67" class="table-link text-info"
                                                       data-toggle="tooltip" data-placement="top" title="编辑"
                                                       data-permission-action="category-update"><i
                                                                class="fa fa-pencil-square-o fa-lg fa-fw"></i></a>
                                                    <a href="javascript:;" class="table-link text-danger js-delete"
                                                       data-toggle="tooltip" data-placement="top" title="删除"
                                                       data-permission-action="category-delete"><i
                                                                class="fa fa-trash-o fa-lg fa-fw"></i></a>
                                                </div>
                                                <div class="delete">
                                                    <a href="javascript:;" class="btn btn-danger js-confirm-delete"
                                                       data-categoryId="67" data-permission-action="category-delete">确定删除</a>
                                                    <a href="javascript:;"
                                                       class="btn btn-default js-delete-cancel">取消</a>
                                                </div>
                                            </td>
                                        </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <footer id="footer-bar" class="row">
                    <p id="footer-copyright" class="col-xs-12">
                        &copy; E乐团购 后台管理系统
                    </p>
                    <p><a href="http://www.miitbeian.gov.cn/">沪ICP备16032507号-2</a></p>
                </footer>
            </div>
        </div>
    </div>
</div>
<!-- START 公用 script -->
@include('backend.global.includeJs')
<script type="text/javascript">
    $(function () {

        var adminPermission = 'category-show,category-new,category-update,category-delete,product-show,product-new,product-update,product-delete,product-sizeList,product-sizenew,product-sizeupdate,product-sizedelete,product-sizecopy,product-combinationnew,product-combinationupdate,product-combinationdelete,jdproduct-show,jdproduct-new,jdproduct-update,jdproduct-delete,jdproduct-pull,role-show,role-new,role-update,role-delete,staff-show,staff-new,staff-update,staff-delete,supplier-show,supplier-new,supplier-update,supplier-delete,agency-show,agency-new,agency-update,agency-delete,order-show,order-new,order-update,order-delete,order-popReturnShipping,order-import,shipment-show,shipment-new,shipment-update,shipment-delete,repertory-show,repertory-new,repertory-update,repertory-delete,user-show,user-new,user-update,user-delete,banner-show,banner-new,banner-update,banner-delete,recommend-show,recommend-new,recommend-update,recommend-delete,coupon-show,coupon-new,coupon-update,coupon-delete,card-show,card-new,card-update,card-delete,card-order,card-popActive,card-popDelete,card-popCancel,card-exchange,card-buynew,card-buy,card-buydetail,card-super,card-supernew,exportcsv-show,category-show,category-new,category-update,category-delete';
        if (adminPermission) {
            adminPermission = adminPermission.split(',');
            $('#nav-col .submenu li').each(function () {
                var permissionAction = $(this).attr('data-permission-action');
                if (permissionAction) {
                    if ($.inArray(permissionAction, adminPermission) == -1) {
                        $(this).remove();
                    }
                }
            })
            $('a[data-permission-action],button[data-permission-action]').each(function () {
                var permissionAction = $(this).attr('data-permission-action');
                if (permissionAction) {
                    if ($.inArray(permissionAction, adminPermission) == -1) {
                        $(this).remove();
                    }
                }
            })
        }

        $('.table-responsive[data-pagi="global"]').on('click', '.pagination a', function () {
            var p = $(this).attr('data-page'), $table = $(this).parents('.table-responsive'),
                pageUrl = $table.data('pageUrl'), $filter = $table.data('filterForm');
            tablePager(pageUrl, p, $table, $filter);
        })
        $('.table-responsive[data-pagi="global"]').on('click', 'a.js-pagijump', function () {
            var $input = $(this).siblings('.form-group').children('input'), inputVal = parseInt($input.val()),
                totalpage = $input.attr('data-total');
            if (!isNaN(inputVal) && inputVal != '' && inputVal <= totalpage) {
                var p = inputVal, $table = $(this).parents('.table-responsive'), pageUrl = $table.data('pageUrl'),
                    $filter = $table.data('filterForm');
                tablePager(pageUrl, p, $table, $filter);
            } else {
                notify(2, '请输入正确的页码');
            }

        })
        $('.table-responsive').on('click', 'input[name="checkAll"]', function () {
            if ($(this).is(':checked')) {
                $('table.table input[name="checkOne"]').prop('checked', false);
            } else {
                $('table.table input[name="checkOne"]').prop('checked', true);
            }
            $('input[name="checkOne"]').trigger('click')
        });
        $('.table-responsive').on('click', 'input[name="checkOne"]', function () {
            if ($(this).is(':checked')) {
                $(this).parents('tr').addClass('info')
            } else {
                $(this).parents('tr').removeClass('info')
            }
        });
    })
    function setTimeOutRedirect(url, time) {
        setTimeout(function () {//两秒后跳转
            window.location.href = url;
        }, 1000);
    }
    function notify(type, messgae, timeout) {
        var icon;
        var tips;
        var showMessage = messgae;
        if (timeout == '')
            timeout = 5000;
        switch (type) {
            case 1:
                icon = 'fa-check-circle';
                tips = 'success';
                break;
            case 2:
                icon = 'fa-warning';
                tips = 'danger';
                break;
        }
        $.notify({
            // options
            icon: 'fa ' + icon,
            message: showMessage
        }, {
            type: tips,
            delay: timeout
        });
    }
    function tablePermission($table) {
        var adminPermission = 'category-show,category-new,category-update,category-delete,product-show,product-new,product-update,product-delete,product-sizeList,product-sizenew,product-sizeupdate,product-sizedelete,product-sizecopy,product-combinationnew,product-combinationupdate,product-combinationdelete,jdproduct-show,jdproduct-new,jdproduct-update,jdproduct-delete,jdproduct-pull,role-show,role-new,role-update,role-delete,staff-show,staff-new,staff-update,staff-delete,supplier-show,supplier-new,supplier-update,supplier-delete,agency-show,agency-new,agency-update,agency-delete,order-show,order-new,order-update,order-delete,order-popReturnShipping,order-import,shipment-show,shipment-new,shipment-update,shipment-delete,repertory-show,repertory-new,repertory-update,repertory-delete,user-show,user-new,user-update,user-delete,banner-show,banner-new,banner-update,banner-delete,recommend-show,recommend-new,recommend-update,recommend-delete,coupon-show,coupon-new,coupon-update,coupon-delete,card-show,card-new,card-update,card-delete,card-order,card-popActive,card-popDelete,card-popCancel,card-exchange,card-buynew,card-buy,card-buydetail,card-super,card-supernew,exportcsv-show,category-show,category-new,category-update,category-delete';
        if (adminPermission) {
            adminPermission = adminPermission.split(',');
            $table.find('a[data-permission-action]').each(function () {
                var permissionAction = $(this).attr('data-permission-action');
                if (permissionAction) {
                    if ($.inArray(permissionAction, adminPermission) == -1) {
                        $(this).remove();
                    }
                }
            })
        }
    }
    function tablePager(pageUrl, page, $table, $filter) {
        if ($filter) {
            $filter.ajaxSubmit({
                type: 'post',
                dataType: 'json',
                data: {page: page},
                success: function (data) {
                    if (data.errorCode == '1') {
                        $table.html(data.returnData.returnHtml);
                        $table.data({'page': page, 'pageUrl': pageUrl, 'filterForm': $filter})
                    } else {
                        notify(data.errorCode, data.message);
                    }
                }
            });
        } else {
            $.ajax({
                type: 'POST',
                url: pageUrl,
                data: {page: page},
                dataType: "json",
                success: function (data) {
                    if (data.errorCode == 1) {
                        $table.html(data.returnData.returnHtml);
                        $table.data({'page': page, 'pageUrl': pageUrl, 'filter': $filter})
                    } else {
                        notify(data.errorCode, data.message);
                    }
                }
            });
        }
    }
</script>    <!-- END 公用 script -->
<!-- START 自定义 script -->
<script type="text/javascript">
    $(function () {
        $('.table').on('click', 'a.js-delete', function () {
            var nml = $(this).parent('.normal');
            nml.hide();
            nml.siblings('.delete').show();
        })
        $('.table').on('click', 'a.js-delete-cancel', function () {
            var del = $(this).parent('.delete');
            del.hide();
            del.siblings('.normal').show();
        })
        $('.js-confirm-delete').on('click', function () {
            var categoryId = $(this).attr('data-categoryId'), tr = $(this).parents('tr');
            if (categoryId) {
                $.ajax({
                    type: 'POST',
                    url: '/adminAjax/deleteCategory/',
                    data: {categoryId: categoryId},
                    dataType: "json",
                    success: function (data) {
                        notify(data.errorCode, data.message);
                        if (data.errorCode == '1') {
                            tr.remove();
                        }
                    }
                });
            }
        })
    })
</script>
<!-- END 自定义 script -->
</html>